package MyByteStream1;

import java.io.FileOutputStream;
import java.io.IOException;

public class MyByteStreamDemo3 {
    public static void main(String[] args) throws IOException {
        //1.创建对象,第二个参数为开关，默认false，当传为true时不会删除原有内容
        FileOutputStream fos = new FileOutputStream("csb.txt",true);
        //2.将要传入的字符串转化为byte类
        String s1 = "zhangdemingzuishual";
        byte[] bytes1 = s1.getBytes();
        //3.将byte数组写入a.txt中
        fos.write(bytes1);
        //4.关闭资源
        //fos.close();

        //换行符为\r\n
        String s2 = "\r\n";
        byte[] bytes2 = s2.getBytes();
        fos.write(bytes2);
        //2.将要传入的字符串转化为byte类
        String s3 = "nishuodetaiduil";
        byte[] bytes3 = s3.getBytes();
        //3.将byte数组写入a.txt中
        fos.write(bytes3);

        fos.write(bytes2);
        //4.关闭资源
        fos.close();
    }
}
